package com.ts.sms.listener;


import com.alibaba.fastjson.JSON;
import com.ts.sms.dto.Sms;
import com.ts.sms.sendUtils.SendSms;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;


@Component
@Slf4j
public class SmsListener {

    @RabbitListener (queues="sms-queue")
    public void getMessage(String message) {
        Sms sms=JSON.parseObject(message, Sms.class);
        log.debug("短信消费者拿到的号码:{}",sms.getPhone());
        log.debug("短信消费者拿到的内容:{}",sms.getContent());
        SendSms.send(sms);
        log.debug("发送短信的方法走完了");
    }
}
